#include <stdio.h>
#include <unistd.h>
#include <iot_gpio.h>
#include <iot_gpio_ex.h>
#include <iot_spi.h>
#include "oled.h"
#include "ohos_init.h"
#include "cmsis_os2.h"
#include "gui.h"

#define OLED_TASK_STACK_SIZE 4096

 /* task处理函数 */
void OLedTask(void * para)
{
    printf("OLED task \r\n");
    OLED_Init();               //初始化OLED  
    OLED_Clear(0);    
    GUI_ShowString(0,0,"lwx2023191130",8,1);//显示字符串(横坐标，纵坐标，字符串，一个字符的长度8/16，颜色)
    GUI_ShowString(0,8,"jhc2023191132",8,1);
    GUI_ShowString(0,16,"hhf2024382027",8,1);
    GUI_DrawCircle(10,44,1,10);
    GUI_FillRectangle(20,25,40,40,1);
    //GUI_ShowChinese(20,20,16,"深大",1)//显示中文,(横坐标，纵坐标，大小，显示的内容，颜色)
    //GUI_DrawBMP(0,0,55,52,clo,1)//显示图片(横坐标，纵坐标，长，宽，显示的内容，颜色)
    OLED_Display();
    return NULL;
}
 /* 创建oled任务函数 */
void oled_demo(void)
{    
    int ret;
    oled_gpio_io_init();
    screen_spi_master_init(0); 
    osThreadAttr_t attr;
 
    attr.name = "OLedTask";
    attr.attr_bits = 0U;
    attr.cb_mem = NULL;
    attr.cb_size = 0U;
    attr.stack_mem = NULL;
    attr.stack_size = OLED_TASK_STACK_SIZE;
    attr.priority = 20;
    if (osThreadNew((osThreadFunc_t)OLedTask, NULL, &attr) == NULL) {
        printf("[OLedExample] Falied to create LedTask1!\n");
    }
}
APP_FEATURE_INIT(oled_demo);